package Animal;

import PolymorphismLearning.Animal;

public class Cat extends Animal {
    private double weight;

    public Cat(){

    }
    public Cat(double weight) {
        this.weight = weight;
    }

    public Cat(String name, double month, double weight) {
        super(name, month);
        this.weight = weight;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    public void sleep(){
        System.out.println("猫睡觉");
    }

    //继承一个类，可以选择重写它的方法,返回类型和参数类型数量必须和父类一致
    //通过super.父类方法名：eat()   可以调用父类方法
    //通过this.自己的方法名：sleep()   可以调用自己的方法
    @Override
    public void eat() {
        super.eat();
        System.out.println("猫吃鱼");
        this.sleep();
    }

    @Override
    public void OverrideSleep() {
        System.out.println("猫睡觉");
    }
}
